package com.wxp.demo05.drawable;

import android.os.Bundle;
import android.view.View;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.wxp.demo05.R;

/**
 * 1.1 形状图形
 */
public class DrawableShapeActivity extends AppCompatActivity implements View.OnClickListener {

    private View v_content;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_drawable_shape);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });

        this.setTitle("1.1 形状图形");
        v_content = this.findViewById(R.id.v_content);
        //设置背景资源 为圆角
        v_content.setBackgroundResource(R.drawable.shape_rect_gold);
        this.findViewById(R.id.btn_rect).setOnClickListener(this);
        this.findViewById(R.id.btn_oval).setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        if (view.getId() == R.id.btn_rect) {
            //设置背景资源 为圆角
            v_content.setBackgroundResource(R.drawable.shape_rect_gold);
        } else if (view.getId() == R.id.btn_oval) {
            //设置背景资源 为椭圆
            v_content.setBackgroundResource(R.drawable.shape_oval_rose);
        }
    }
}